﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calories
{
    class Program
    {
        static void Main(string[] args)
        {
            /* Pseudocode for this program:
             * input fatGrams
             * input carbGrams
             * calFat = fatGrams * 9
             * calCarb = carbGrams * 4
             * display calories from fat, calories from carbs
             */
            string loop = "Y";
            int fatGrams = 0, carbGrams = 0, fatCal = 0, carbCal = 0;
            while (loop.ToUpper() == "Y")
            {
                print("We will now calculate the calories you have taken from food you ate today.");
                getFatGrams(ref fatGrams);
                getCarbGrams(ref carbGrams);
                calculateCalories(ref fatCal, ref carbCal, fatGrams, carbGrams);
                Console.WriteLine("The total calories you have taken from food are: {0}\nOut of those {1} are from Fat and {2} from carbs.", fatCal + carbCal, fatCal, carbCal);
                //displayResults();
                print("Type Y to calculate aother day of calories or any other key to end the program");
                loop = Console.ReadLine();
            }
        }
        static void getFatGrams(ref int fatGrams)
        {
            print("Please provide the total Grams of fat you have taken today");
            while (!int.TryParse(Console.ReadLine(), out fatGrams))
            {
                print("You need to provide a Whole number, no decimals or fractions.");
            }
        }
        static void getCarbGrams(ref int carbGrams)
        {
            print("Please provide the total Grams of fat you have taken today");
            while (!int.TryParse(Console.ReadLine(), out carbGrams))
            {
                print("You need to provide a Whole number, no decimals or fractions.");
            }
        }
        static void calculateCalories(ref int fatCal,ref int carbCal,int fatGrams,int carbGrams)
        {
            fatCal = fatGrams * 9;
            carbCal = carbGrams * 4;
        }
        static void print(string text)
        {
            Console.WriteLine("\n{0}",text);
        }
    }
}
